#!/usr/expect/bin/expect

set src_file [lindex $argv 1]
set dest_file [lindex $argv 2]
set password [lindex $argv 0]

spawn scp -r $src_file $dest_file
#spawn scp -r /ftpdata/bsmp/data/20160222/$filename root@gd-gz-sx-dn-111:/ftpdata/bsmp/data/

expect {
        "(yes/no)?"
                {
                        send "yes\n"
                        expect "*assword:" {send "$password\n"}
                }
        "*assword:"
                {
                        send "$password\n"
                }
}
expect "100%"
expect eof 
